
// TODO javadoc & license

package br.com.music.rhythm;

import br.com.music.Duration;
import br.com.music.player.Playable;

// TODO: make different beat types possible.

/**
 * TODO javadoc
 */
public class Beat implements Playable {

    public static final int WEAK = 1;
    public static final int MEDIUM = 2;
    public static final int STRONG = 3;

    /** Default acoustic instrument used to produce the beat. */
    private String type = "[Hi_Bongo]";

    /** Beat strength is represented in JFugue as simultaneous beats. */
    private Integer strength = 0;

    /** Beat duration. */
    private Duration duration = Duration.SEMIBREVE;

    /**
     * Class constructor.
     *
     * @param strength Beat strength.
     */
    Beat(Integer strength) {
        this.strength = strength;
    }

    /**
     * Class constructor.
     * @param strength Beat strength.
     * @param duration Beat duration.
     */
    Beat(Integer strength, Duration duration) {
        this.strength = strength;
        this.duration = duration;
    }

    /**
     * Set beat strength. It's polite to use default values Beat.WEAK,
     * Beat.MEDIUM and beat.STRONG, even though it's possible to use
     * higher values of strength.
     *
     * @note Developers never stressed the sequencer to check the bounds. :-)
     * 
     * @param strength Strength is an Integer; higher values means stronger.
     */
    public void setStrength(Integer strength) {
        this.strength = strength;
    }

    /**
     * Get beat strength.
     *
     * @return This method returns the strength as Integer. Higher values means
     * stronger beats.
     */
    public Integer getStrength() {
        return this.strength;
    }

    /**
     * Set beat duration.
     *
     * @param duration Duration.
     */
    public void setDuration(Duration duration) {
        this.duration = duration;
    }

    /**
     * TODO javadoc
     *
     * @return
     */
    public Duration getDuration() {
        return this.duration;
    }


    /**
     * TODO javadoc
     *
     * @return
     */
    @Override
    public String toString() {
        String str = "V9 ";
        for(int i = 0; i < this.strength; i++) {
            str += (this.type + this.duration);
            str += (i+1 != this.strength) ? "+" : " ";
        }
        return str;
    }

}
